package cn.wolfcode.luowowo.common.util;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class AjaxResult {

    private boolean success=true;
    private String msg;
    private int code;
    private Object data;

    public AjaxResult() { }
    public AjaxResult(boolean success){
        this.success = success;
    }

    public AjaxResult(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    //成功时直接调用这个静态常量就行(因为有默认值true)
    public static final AjaxResult SUCCESS = new AjaxResult();

    //失败时用(这个其实不需要,统一异常类已经帮我妈处理了失败的情况)
    public static final AjaxResult FAIL = new AjaxResult(false);

    public AjaxResult addData(Object data){
        this.data=data;
        return this;
    }
}
